/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.farmcode.console.ejb.business.custom;

import com.farmcode.base.dao.BaseFilter;
import com.farmcode.base.dao.DAOException;
import com.farmcode.base.manager.FacadeException;
import com.farmcode.console.api.business.BaseMatchContextManagerBean;
import com.farmcode.console.api.business.custom.ExtMatchContextManager;
import com.farmcode.console.api.model.Match;
import com.farmcode.console.api.model.MatchContext;
import java.util.List;
import javax.ejb.Local;
import javax.ejb.Stateless;

/**
 *
 * @author Oscar Ivan Prado
 */
@Local(ExtMatchContextManager.class)
@Stateless
public class ExtMatchContextManagerBean extends BaseMatchContextManagerBean implements ExtMatchContextManager{

    @Override
    public List<MatchContext> getMatchContextByMatch(Match match) throws FacadeException {
        try {
            return matchContextDAO.find(new MatchContextFilter(match));
        } catch (DAOException ex) {
            throw new FacadeException(ex);
        }
    }
    
    class MatchContextFilter extends BaseFilter{
        
        private Match match;

        public MatchContextFilter(Match match) {
            this.match = match;
        }
        
        @Override
        public void fill() {
            setParameter("math", "matchContext.match = ", match);
        }
        
    }
}
